$(function(){
    //获取url参数
	function GetQueryString(name){
		var reg = new RegExp("(^|&)"+name+"=([^&]*)(&|$)");
		var r = window.location.search.substr(1).match(reg);
		if(r!=null)return unescape(r[2]); return null;
    }

    exportExcel=function(){
        excel=new Object();
        grade=GetQueryString('grade');
        excel.grade=grade==null?$("#grade_select").val():grade;

        major=GetQueryString('major');
        excel.major=major==null?$("#major_select").val():major;

        classs=GetQueryString('class');
        excel.class=classs==null?$("#class_select").val():classs;

        search=GetQueryString('search');
        excel.search=search==null?$("#search").val():search;
        
        excelJSON=JSON.stringify(excel);
        //creatIframe('./php/student-dormitory-list.php?action=1&data='+excelJSON,'下载');
        window.location.href='./php/student-dormitory-list.php?action=1&data='+excelJSON;
    }

    $("select").change(function(){
        var id=$(this).attr("id");
        switch(id){
            case "jump_page":
                //var allocate=GetQueryString('allocate');
                //allocate=allocate==null?0:allocate;
        
                var grade=GetQueryString('grade');
                grade=grade==null?0:grade;
        
                var major=GetQueryString('major');
                major=major==null?0:major;
        
                var classs=GetQueryString('class');
                classs=classs==null?0:classs;
        
                //var gender=GetQueryString('gender');
                //gender=gender==null?0:gender;
        
                //var page=GetQueryString('page');
                //page=page==null?0:page;
        
                var search=GetQueryString('search');
                search=search==null?'':search;

                url="./student-dormitory-list.php?grade="+grade
                +"&major="+major+"&class="+classs+"&page="+$(this).val()+"&search="+search;
				window.location.href=url;
            break;
            default:break;
        }
    });
});